package com.example.treehole;

import android.view.View;

import com.example.treehole.base.BaseBindingActivity;
import com.example.treehole.databinding.ActivityCallBackBinding;
import com.example.treehole.util.Api;
import com.example.treehole.util.HttpUtil;
import com.example.treehole.util.SomeUtil;

import java.util.HashMap;

public class CallBackActivity extends BaseBindingActivity<ActivityCallBackBinding> {
    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        viewBinder.tvSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String content = viewBinder.etContent.getText().toString();
                if (content.isEmpty()) {
                    toast("请输入建议内容");
                    return;
                }
                showLoading();
                HashMap<String, Object> params = new HashMap<>();
                params.put("userid", App.user.id);
                params.put("content", content);
                params.put("callback", "");
                params.put("time", SomeUtil.getTime());
                HttpUtil.post(Api.CALLBACK_ADD, params, new HttpUtil.OnNetStringListener() {
                    @Override
                    public void success(String data, String message) {
                        display$Toast(message);
                        setResult(RESULT_OK);
                        finish();
                    }

                    @Override
                    public void error(String message) {
                        display$Toast(message);
                    }
                });
            }
        });
    }
}